package com.eaoa.uc.dictionary.bo;

import java.util.Iterator;

import com.eaoa.base.EABaseBusinessObject;
import com.eaoa.dao.pub.PubDDItemDAO;
import com.eaoa.dao.pub.PubDatadictionaryDAO;
import com.eaoa.query.pub.PubDatadictionaryQuery;
import com.eaoa.vo.pub.PubDatadictionary;
import com.eaoa.vo.pub.PubDditem;

/**
 * DDictionary Delete
 * @author zhenglun.zhou
 *
 */
public class DDictionaryDeleteBO extends EABaseBusinessObject {

	private Long ddno;
	private PubDatadictionaryDAO dictionaryDAO = new PubDatadictionaryDAO();
	private PubDDItemDAO dictionaryItemDAO = new PubDDItemDAO();

	public DDictionaryDeleteBO(Long ddno) {
		super();
		this.ddno = ddno;
	}
	

	protected void performBusinessLogic() {
		
		PubDatadictionary dictionary = PubDatadictionaryQuery.loadByNoNotLazy(ddno);
		
		Iterator items = dictionary.getPubDditems().iterator();
		while(items.hasNext()){
			PubDditem item = (PubDditem)items.next();
			dictionaryItemDAO.deleteByID(item.getItemno());
		}
		
		dictionaryDAO.deleteByID(ddno);	

	}
}